package com.gan.exp01.controller;

import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @RequestMapping("/test")
    public String index(){
        return "hello world!";
    }


    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext apc) {
        return args ->  {
            System.out.println("spring boot 注册的所有bean!");
            String beanName[]=apc.getBeanDefinitionNames();
            for (String beans:beanName) {
                System.out.println(beans);

            }
        };
    }
}
